﻿using System.Windows;
using System.Windows.Input;
using Poet.ViewModels;

namespace Poet.Views
{
    /// <summary>
    /// Interaction logic for SaveView.xaml
    /// </summary>
    public partial class SaveView
    {
        public SaveView()
        {
            InitializeComponent();
            Owner = Application.Current.MainWindow;
            Closing += (sender, args) => DialogResult = ((SaveViewModel) DataContext).DialogResult;
            Activated += (sender, args) =>
                {
                    Focus();
                    PreviewKeyDown += SetFocus;
                };

            DataContextChanged += (sender, args) => ContextMenu.DataContext = DataContext;
        }

        public void SetFocus(object sender, KeyEventArgs keyEventArgs)
        {
            SaveButton.Focus();
            PreviewKeyDown -= SetFocus;
        }
    }
}
